/*
 * StringOutputStream.java
 * 
 * Copyright (c) 2009 Barraquand Remi <dev at barraquand.com>. All rights reserved.
 * 
 * This file is part of JenaTools
 *
 * JenaTools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JenaTools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JenaTools. If not, see <http://www.gnu.org/licenses/>.
 */

package com.barraquand.labs.jenatools;

import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;

/**
 *
 * @author Barraquand Remi
 */
 public class StringOutputStream extends OutputStream implements Serializable {

    protected StringBuffer buffer = new StringBuffer();

    @Override
    public void write(byte[] b) throws IOException {
        buffer.append(new String(b));
    }

    @Override
    public void write(byte[] b, int off, int len) throws IOException {
        buffer.append(new String(b, off, len));
    }

    public void write(int b) throws IOException {
        byte[] byteArr = new byte[] { (byte) b };
        buffer.append(new String(byteArr));
    }

    @Override
    public String toString() {
        return buffer.toString();
    }
 }
